var PagingTool = {
    // 生成分页代码
	getPagingCode : function(tabName, condition,funName, totalPageCount, pageNo,pageSize,totalRecordCount) {
        
        var pagingCode = '<table width="100%" border="0" align="right" cellpadding="0" cellspacing="0">'
                       + '<tr><td align="left">';
        // 首页和上一页按钮 
        if (pageNo > 1) {
            pagingCode += '&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="javascript:'+funName+'(\'' + tabName + '\',\'' + condition + '\', 1);">首页</a>';
            pagingCode += '&nbsp;<a href="javascript:void(0);" onclick="javascript:'+funName+'(\'' + tabName + '\',\'' + condition + '\', ' + (pageNo - 1) + ');">上页</a>';
        } else {
            pagingCode += '&nbsp;&nbsp;&nbsp;<span class="disabled">首页</span>';
            pagingCode += '&nbsp;<span class="disabled">上页</span>';
        }
          pagingCode += '&nbsp;<span><b> 第' + pageNo + '页</b></span>';
        // 下一页和末页按钮
        if (pageNo < totalPageCount) {
            pagingCode += '&nbsp;<a href="javascript:void(0);" onclick="javascript:'+funName+'(\'' + tabName + '\',\'' + condition + '\', ' + (pageNo + 1) + ');">下页</a>';
            pagingCode += '&nbsp;<a href="javascript:void(0);" onclick="javascript:'+funName+'(\'' + tabName + '\',\'' + condition + '\', ' + totalPageCount + ');">末页</a>';
        } else {
            pagingCode += '&nbsp;<span class="disabled">下页</span>';
            pagingCode += '&nbsp;<span class="disabled">末页</span>';
        }
         pagingCode += '</td>'
                    + '<td align="right"><div id="egg">'
                    + '<div>';
        if(totalRecordCount<=pageSize) {
          pagingCode += '<div><span class="disabled">当前1'+'-'+totalRecordCount+'</span>,';
        } else if(pageNo==totalPageCount) {
          pagingCode += '<div><span class="disabled">当前'+((pageNo-1)*pageSize+1)+'-'+totalRecordCount+'</span>,';
        } else if (pageNo<totalPageCount) {
          pagingCode += '<div><span class="disabled">当前'+((pageNo-1)*pageSize+1)+'-'+(pageNo*pageSize)+'</span>,';
        }
     
        pagingCode += '<span class="disabled">共'+totalRecordCount+'条记录</span></div></div></div>';
        pagingCode += '</td></tr></table>';

        return pagingCode;
    }
};


var PagingToolV2 = {
    // 生成分页代码
	getPagingCode : function(inputid,condition,funName, totalPageCount, totalPageSize,pageNo) {
		var pagingCode="";
		pagingCode = "<div class=\"pagetext\"><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"right\">到<input name=\"go\" type=\"text\" id=\""+inputid+"\" size=\"5\" style=\"width:30px;\"/>页</td><td align=\"right\">共"+totalPageSize+"条记录</td></tr></table></div>";
     
        pagingCode+= '<div class=\"pagemub\">'+pageNo+"/"+totalPageCount+'</div>';
       
      if (pageNo < totalPageCount) {
            pagingCode += '<a href="javascript:;" onclick="javascript:'+funName+'(\'' +  condition + '\', ' +totalPageCount+ ');"> <div class="pagerightfast"></div> </a>';
            pagingCode += '<a href="javascript:;" onclick="javascript:'+funName+'(\'' +  condition + '\', ' +(pageNo + 1) + ');"> <div class="pageright"></div> </a>';
        } else {
            pagingCode += '<div class="pagerightfast"></div>'; 
            pagingCode += '<div class="pageright"></div>';
        }   
       
        var star=0;
        var end=0;
        if(pageNo==1){
        	 if(totalPageCount>=5){
	           star=pageNo+4;
	           end=pageNo;	
            }else{
               star=totalPageCount;
               end=1;
            }
        }else if(totalPageCount==pageNo){
        	 star=totalPageCount;
        	 if(totalPageCount<5){
        	    end=1;
        	 }else{
                end=totalPageCount-4;
             }	
        }else{
           star=pageNo+3;
           end=star-4;	
           if(star>totalPageCount){
              star=totalPageCount;
              if(totalPageCount<5){
        	    end=1;
        	 }else{
                end=totalPageCount-4;
             }		
           }
        }
        for (var j=star; j>=end; j--) {
            if (j == pageNo) {
                pagingCode += '<div class="pagesel">' + j + '</div>';
            } else {
                pagingCode += '<a href="javascript:;" onclick="javascript:'+funName+'(\'' + condition + '\', ' + j+ ');"><div class="pagenormal">' + j + '</div></a>';
            }
        }
       
        if (pageNo > 1) {
            pagingCode += '<a href="javascript:;" onclick="javascript:'+funName+'(\'' +condition + '\',  ' + (pageNo - 1) + ');"><div class="pageleft"></div></a>';
            pagingCode += '<a href="javascript:;" onclick="javascript:'+funName+'(\'' + condition + '\', 1);"> <div class="pageleftfast"></div></a>';
        } else {
            pagingCode += '<div class="pageleft"></div>';
            pagingCode += '<div class="pageleftfast"></div>';
        }
        return pagingCode;
    }
};
